// SKNotes - a note taking and gathering tool
// Copyright (C) 2009  Stefan Kueng
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

namespace SKNotes.Configuration
{
    using System;
    using System.ComponentModel;

	public delegate void SettingValueCancelEventHandler( object sender, SettingValueCancelEventArgs e );

	public class SettingValueCancelEventArgs : CancelEventArgs
	{
		public SettingValueCancelEventArgs( ISetting setting, string name, object value ) :
			this( setting, name, value, false )
		{
		}

        public SettingValueCancelEventArgs( ISetting setting, string name, object value, bool cancel ) :
			base( cancel )
		{
			if ( setting == null )
			{
				throw new ArgumentNullException( "setting" );
			}
			if ( string.IsNullOrEmpty( name ) )
			{
				throw new ArgumentNullException( "name" );
			}
			if ( value == null )
			{
				throw new ArgumentNullException( "value" );
			}

			this.setting = setting;
			this.name = name;
			this.value = value;
			this.targetValue = value;
		} 

		public ISetting Setting
		{
			get { return this.setting; }
		}

		public string Name
		{
			get { return this.name; }
		}

		public bool HasValue
		{
			get { return this.value != null; }
		}

		public object Value
		{
			get { return this.value; }
		}

		public object TargetValue
		{
			get { return this.targetValue; }
			set { this.targetValue = value; }
		}

        private readonly ISetting setting;
		private readonly string name;
		private readonly object value;
		private object targetValue;

	}
} 
